
<%@ Page language="c#" debug="true"%>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Collections" %>
<%@ Import Namespace="System.Collections.Specialized" %>
<%@ Import Namespace="System.Text" %>
<%@ Import Namespace="System.Globalization" %>
<%@ Import Namespace="OSGeo.MapGuide" %>
<%@ Import Namespace="Jayrock.Json" %>
<%@ Import Namespace="Jayrock.Json.Conversion" %>

<!-- #Include File="classes/theme.aspx -->
<!-- #Include File="classes/command.aspx -->
<%
    InitializeWebTier();

    NameValueCollection args = GetRequestParameters();
    Theme theme = new Theme(args);
    String responseType = "";
    String responseString = "";

    if(GetParameter(args, "COMMAND") != null)
    {
        int cmd = Int32.Parse(GetParameter(args, "COMMAND"));
        switch (cmd)
        {
            case Command.GETLAYERINFO:
                responseType = "text/plain";
                responseString = JsonConvert.ExportToString(theme.GetLayerInfo());
                break;
            case Command.GETPROPERTYMINMAXCOUNT:
                responseType = "text/plain";
                responseString = JsonConvert.ExportToString(theme.GetPropertyMinMaxCount());
                break;
            case Command.APPLYTHEME:
                responseType = "text/plain";
		        responseString = JsonConvert.ExportToString(theme.ApplyTheme());
                break;
        }
    }
    Response.ContentType = responseType;
    Response.Write(responseString);
%>